package org.huawei260.TiKu.ODsuanfa;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
import java.util.Scanner;
import java.util.stream.Collectors;
public class E_2024E_2850__哈希表_斗地主之顺子 { //65%

//	public class Main {
		public static void main(String[] args) {
			Scanner sc = new Scanner(System.in);
			String[] cards = sc.nextLine().split(" ");
			getResult(cards);
		}

		public static void getResult(String[] cards) {
			Arrays.sort(cards, (a, b) -> mapToNum(a) - mapToNum(b));

			ArrayList<LinkedList<String>> straights = new ArrayList<>();
			straights.add(creatStraight(cards[0]));

			outer:
			for (int i = 1; i < cards.length; i++) {
				String card = cards[i];

				for (LinkedList<String> s : straights) {
					if (mapToNum(card) - mapToNum(s.getLast()) == 1) {
						s.add(card);
						continue outer;
					}
				}

				straights.add(creatStraight(card));
			}

			List<LinkedList<String>> collect =
				straights.stream().filter(straight -> straight.size() >= 5).collect(Collectors.toList());

			if (collect.size() == 0) {
				System.out.println("No");
				return;
			}

			collect.stream()
				.sorted((a, b) -> mapToNum(a.getFirst()) - mapToNum(b.getFirst()))
				.forEach(straight -> System.out.println(String.join(" ", straight)));
		}

		public static LinkedList<String> creatStraight(String card) {
			LinkedList<String> straight = new LinkedList<>();
			straight.add(card);
			return straight;
		}

		public static int mapToNum(String card) {
			switch (card) {
				case "J":
					return 11;
				case "Q":
					return 12;
				case "K":
					return 13;
				case "A":
					return 14;
				case "2":
					return 16;
				default:
					return Integer.parseInt(card);
			}
		}
	}